package com.lyfx.ly.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.lyfx.ly.entity.StudyStepReadContentEntity;
import com.lyfx.ly.service.StudyStepReadContentService;
import com.lyfx.common.utils.PageUtils;
import com.lyfx.common.utils.R;



/**
 * **学习表拆分内容太大
 *
 * @author lsy
 * @email lsy@gmail.com
 * @date 2020-07-05 18:03:59
 */
@RestController
@RequestMapping("ly/studystepreadcontent")
public class StudyStepReadContentController {
    @Autowired
    private StudyStepReadContentService studyStepReadContentService;

    /**
     * 列表
     */
    @RequestMapping("/list/info/{stepId}")
    @RequiresPermissions("ly:studystepreadcontent:list")
    public R list(@PathVariable("stepId") Long stepId){
        StudyStepReadContentEntity step_id = studyStepReadContentService.getOne(new QueryWrapper<StudyStepReadContentEntity>().eq("step_id", stepId));
        return R.ok().put("data", step_id);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("ly:studystepreadcontent:info")
    public R info(@PathVariable("id") Long id){
		StudyStepReadContentEntity studyStepReadContent = studyStepReadContentService.getById(id);

        return R.ok().put("studyStepReadContent", studyStepReadContent);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("ly:studystepreadcontent:save")
    public R save(@RequestBody StudyStepReadContentEntity studyStepReadContent){
		studyStepReadContentService.save(studyStepReadContent);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("ly:studystepreadcontent:update")
    public R update(@RequestBody StudyStepReadContentEntity studyStepReadContent){
		studyStepReadContentService.updateById(studyStepReadContent);

        return R.ok();
    }
    /**
     * 修改
     */
    @RequestMapping("/edit/info")
    @RequiresPermissions("ly:studystepreadcontent:update")
    public R updateInfo(@RequestBody StudyStepReadContentEntity studyStepReadContent){
        studyStepReadContentService.update(studyStepReadContent,new QueryWrapper<StudyStepReadContentEntity>().eq("step_id", studyStepReadContent.getStepId()));
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("ly:studystepreadcontent:delete")
    public R delete(@RequestBody Long[] ids){
		studyStepReadContentService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
